package com.kong.multids.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.kong.multids.mapper.DogMapper;
import com.kong.multids.model.Dog;
import com.kong.multids.model.DogExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author gedachao
 * @description 测试ds2
 * @date 2020/5/30 16:27
 */
@Service
public class Service3Impl {

    @Autowired
    DogMapper dogMapper;


    @DS("ds2")
    public List<Dog> getDogs(){
        DogExample dogExample = new DogExample();
        List<Dog> dogs = dogMapper.selectByExample(dogExample);
        return dogs;
    }

    @Transactional
    @DS("ds2")
    public void addDog(Dog dog){
        dogMapper.insert(dog);
    }

}
